package logic.netSerer.GUI.nettyServer;

import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import logic.util.EasyLog;

public class NettyServerHandle extends ChannelHandlerAdapter{

	public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception{
		EasyLog.info(getClass(), "服务端收到消息:{}", msg);
		ctx.writeAndFlush("服务端收到了: "+msg.toString());
		ctx.writeAndFlush("msg from server.");
		ctx.writeAndFlush("quit.");
	}
	public void write(ChannelHandlerContext ctx,Object msg, ChannelPromise channelPromise) throws Exception{
		EasyLog.info(getClass(), "服务端发送消息:{}", msg);
	}
	public void disconnect(ChannelHandlerContext ctx, ChannelPromise channelPromise){
		EasyLog.info(getClass(), "客户端断开连接.");
	}
	
	public void channelActive(ChannelHandlerContext ctx) throws Exception{
		EasyLog.info(getClass(), "信道激活.");
	}
	public void exceptionCaught(ChannelHandlerContext ctx,Throwable t) throws Exception{
		EasyLog.error(getClass(), t);
		
	}


}
